/*
Once upon a time, there was a girl who picked grapes ......
"The young girl crushed grapes, squirted juice, and crushed 
grapes again. The feeling of roundness and softness gradually 
turns into a weird touch like stepping on a water-soaked beach."
Do you remember?
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mem(x) memset(x,0,sizeof(x))
#define endl "\n"
#define printYes cout << "Yes\n"
#define printYES cout << "YES\n"
#define printNo cout << "No\n"
#define printNO cout << "NO\n"
#define lowbit(x) ((x)&(-(x)))
#define pb push_back
#define mkp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define rep(i,j,k) for (int i=(j);i<=(k);i++)
#define per(i,j,k) for (int i=(j);i>=(k);i--)
#define pcnt(x) __builtin_popcount(x)
mt19937 rnd(time(0));
template<class T>void chkmin(T&x,T y){x=min(x,y);}
template<class T>void chkmax(T&x,T y){x=max(x,y);}

const ll inf=1000000000000000000; 
//const ll inf=1000000000;
//const ll mod=998244353;
//const ll mod=1000000007;

const int N=5e5+5;
int n,m,q,cnt;
struct rect
{
	int x1,x2,y1,y2;
	bool operator < (const rect &x)
	{
		if (x1!=x.x1) return x1<x.x1;
		if (x2!=x.x2) return x2<x.x2;
		if (y1!=x.y1) return y1<x.y1;
		return y2<x.y2;
	}
}a[N],g[N*2];
rect operator + (const rect &x,const rect &y)
{
	rect res;
	res.x1=min(x.x1,y.x1);
	res.x2=max(x.x2,y.x2);
	res.y1=min(x.y1,y.y1);
	res.y2=max(x.y2,y.y2);
	return res;
}
inline ll S(rect x)
{
	return 1ll*(x.x2-x.x1+1)*(x.y2-x.y1+1);
}
bool vis[N*2];
bool cmp(rect x,rect y)
{
	return x.x2<y.x2;
}
namespace DS
{
	const int M=524388*2;
	vector<pii> c[M],d[M];
	inline void add(int u,pii x,int tp)
	{
		if (tp==0) c[u].push_back(x);
		else d[u].push_back(x);
	}
	inline pii top(int u,int tp)
	{
		if (tp==0)
		{
			while (c[u].size()&&vis[c[u].back().se]) c[u].pop_back();
			if (c[u].size()==0) return mkp(-3,-3);
			else return c[u].back();
		}
		else
		{
			while (d[u].size()&&vis[d[u].back().se]) d[u].pop_back();
			if (d[u].size()==0) return mkp(-3,-3);
			else return d[u].back();
		}
	}
	void update(int u,int L,int R,int l,int r,int tp,pii x)
	{
		if (l<=L&&R<=r)
		{
			add(u,x,0);
			return;
		}
		add(u,x,1);
		int mid=(L+R)>>1;
		if (l<=mid) update(u*2,L,mid,l,r,tp,x);
		if (mid<r) update(u*2+1,mid+1,R,l,r,tp,x);
	}
	pii ask(int u,int L,int R,int l,int r)
	{
		pii res=top(u,0);
		if (l<=L&&R<=r) return max(res,top(u,1));
		int mid=(L+R)>>1;
		if (l<=mid) res=max(res,ask(u*2,L,mid,l,r));
		if (mid<r) res=max(res,ask(u*2+1,mid+1,R,l,r));
		return res;
	}
}


int main()
{
	freopen("grid.in","r",stdin);
	freopen("grid.out","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m >> q;
	rep(i,1,q) cin >> a[i].x1 >> a[i].y1;
	rep(i,1,q) a[i].x2=a[i].x1,a[i].y2=a[i].y1;
	int maxc=max(n,m);
	sort(a+1,a+q+1,cmp);
	int tot=0;
	for (int i=1;i<=q;i++)
	{
		rect x=a[i];
		while (1)
		{
			g[++tot]=x;
			pii res=DS::ask(1,1,maxc,max(x.y1-2,1),min(x.y2+2,maxc));
			if (res.fi>=x.x1)
			{
				vis[res.se]=1,vis[tot]=1;
				x=x+g[res.se];
				continue;
			}
			res=DS::ask(1,1,maxc,max(x.y1-1,1),min(x.y2+1,maxc));
			if (res.fi>=x.x1-1)
			{
				vis[res.se]=1,vis[tot]=1;
				x=x+g[res.se];
				continue;
			}
			res=DS::ask(1,1,maxc,max(x.y1,1),min(x.y2,maxc));
			if (res.fi>=x.x1-2)
			{
				vis[res.se]=1,vis[tot]=1;
				x=x+g[res.se];
				continue;
			}
			break;
		}
		DS::update(1,1,maxc,x.y1,x.y2,1,mkp(x.x2,tot));	
	}
	ll ans=0;
	rep(i,1,tot) if (!vis[i]) ans+=S(g[i]);
	cout << ans;
	return 0;
}

